<template>
    <el-upload :accept="accept" :autoUpload="false" v-model:fileList="files" withCredentials :before-upload="beforeAvatarUpload"
        :disabled="disabled">
        <el-link type="primary">选择文件...</el-link>
    </el-upload>
</template>
<script setup>
    const props = defineProps({
        accept: String,
        disabled: Boolean
    })

    const files = ref([])

    function beforeAvatarUpload(rawFile) {
        if (rawFile.size / 1024 / 1024 > 5) {
            ElMessage.error('大小不能超出5M')
            return false
        }
        return true
    }
</script>

<style lang='scss' scoped></style>